//实现Runnable接口
class MyRunnable implements Runnable{
    @Override
    public void run() {
        while(true) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            System.out.println("正在运行,Thread/run");
        }
    }
}
public class ThreadDemo2 {
    public static void main(String[] args) throws InterruptedException {
        //2) 创建 Thread 类实例, 调用 Thread 的构造方法时将 Runnable 对象作为 target 参数.
        //Runnable  runnable= new MyRunnable();
        Thread t = new Thread(new MyRunnable());
        //3.调用Thread类中的start方法
        //表示线程开始
        System.out.println("要开始创建线程了");
        t.start();
        while (true) {
           Thread.sleep(1000);
            System.out.println("正在运行,main");
        }
    }
}
